Skip to content

fix(observability): add TTL-based eviction to prevent memory leak (#563) - #881

Open
Seunfunmi-319509 wants to merge 3 commits into
Iris-IV:mainfrom
Seunfunmi-319509:fix/563-observability-memory-leak-ttl-eviction
Open

fix(observability): add TTL-based eviction to prevent memory leak (#563)#881
Seunfunmi-319509 wants to merge 3 commits into
Iris-IV:mainfrom
Seunfunmi-319509:fix/563-observability-memory-leak-ttl-eviction

Conversation

@Seunfunmi-319509

Copy link
Copy Markdown

The module-level events array in metricsStore.ts grew without time-based bounds in long-running Node.js processes. Added a purgeStaleEvents() function that removes events older than 1 hour on every ingest and snapshot read, complementing the existing MAX_EVENTS size cap.

Summary

Closes #563

Type of Change

  • Bug fix
  • Feature
  • Chore / maintenance
  • Documentation
  • Test coverage

Contributor Checklist

  • Linked the related issue above.
  • Reviewed CONTRIBUTING.md for branch, commit, and PR title conventions.
  • Confirmed this follows the current Stellar Wave contribution flow, if applicable.
  • Added or updated tests when behavior changed.
  • Updated docs, examples, or translations when needed.

Validation

  • npm run lint
  • npm run format:check
  • npm run typecheck
  • npm test
  • npm run build
  • Not run; reason:

Notes for Reviewers

…is-IV#563)

The module-level events array in metricsStore.ts grew without time-based
bounds in long-running Node.js processes. Added a purgeStaleEvents()
function that removes events older than 1 hour on every ingest and
snapshot read, complementing the existing MAX_EVENTS size cap.
@drips-wave

drips-wave Bot commented Jul 30, 2026

Copy link
Copy Markdown

@Seunfunmi-319509 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@sshdopey

Copy link
Copy Markdown
Contributor

Auto-review failed (API error). Leaving PR for human review.

@sshdopey

Copy link
Copy Markdown
Contributor

Auto-review failed (API error). Leaving PR for human review.

Comment thread scripts/check-i18n.mjs
const parts = fullKey.split(".");
const key = parts[parts.length - 1];
const namespace = parts.length > 1 ? parts[0] : '';
const namespace = parts.length > 1 ? parts[0] : "";
…MESSAGE error in NotificationBell/NotificationSettings
@sshdopey

Copy link
Copy Markdown
Contributor

Auto-review failed (API error). Leaving PR for human review.

@davidmaronio davidmaronio left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the core metricsStore change is solid: purgeStaleEvents correctly exploits insertion order with findIndex plus splice, clears the whole buffer when everything is stale, and purging on both ingest and snapshot reads keeps the TTL and the existing MAX_EVENTS cap complementary. good, focused design for the actual fix.

the problem is the rest of the diff. the PR touches ~20 unrelated files (README, i18n scripts, WalletContext, DonationContext, contractClient, CampaignMap, e2e specs, etc). your branch was cut from the broken main state that #875 later fixed, so those hunks would re-revert other people's work if merged as is.

  1. please rebase onto current main so the diff only contains src/lib/observability/metricsStore.ts (plus a test). everything outside observability should disappear from the diff.
  2. src/lib/observability/metricsStore.ts: there is no unit test for the new TTL behavior. please add one covering the three purge cases (some stale at front, all stale, none stale) using a fake now.
  3. heads up on merge order: #767 (rate limiting) is expected to land first and #784 (auth) also touches this observability surface. after those merge you will need to re-check that ingest still calls purgeStaleEvents exactly once per event and that rate-limit counters are not fed from purged events.

ci is red mostly because of the stale base, so a clean rebase should also fix lint and playwright.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] observability recordObservabilityKind/Failure calls persist state to module-level Map — memory leak in long-running process

4 participants